
'use strict'

const { Sequelize, DBPoolSquare } = require('./mysqldb')

const RecommendCategory = function() {
  return DBPoolSquare.define(
    'recommend_category',
    {
      category_name: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 255
      },
      on: {
        type: Sequelize.BOOLEAN,
        allowNull: false,
        defaultValue: true
      }
    },
    {
      tableName: 'recommend_category',
      timestamps: true
    }
  )
}

const RecommendPlaylist = function() {
  return DBPoolSquare.define(
    'recommend_playlist',
    {
      category_id: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      production_id: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      image: {
        type: Sequelize.BLOB,
        allowNull: false
      }
    },
    {
      tableName: 'recommend_playlist',
      timestamps: true
    }
  )
}

const SceneInfo = function() {
  return DBPoolSquare.define(
    'scene_info',
    {
      scene_name: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 64
      },
      image: {
        type: Sequelize.BLOB,
        allowNull: false
      },
      begin_at: {
        type: Sequelize.TIME,
        allowNull: false,
        defaultValue: '00:00:00'
      },
      end_at: {
        type: Sequelize.TIME,
        allowNull: false,
        defaultValue: '00:00:00'
      },
      next_scene_id: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      introduction: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        length: 255
      },
      on: {
        type: Sequelize.BOOLEAN,
        allowNull: false,
        defaultValue: true
      }
    },
    {
      tableName: 'scene_info',
      timestamps: true
    }
  )
}

const ScenePlaylist = function() {
  const tbl = DBPoolSquare.define(
    'scene_playlist',
    {
      scene_id: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      },
      production_id: {
        type: Sequelize.BIGINT,
        allowNull: false,
        defaultValue: 0
      }
    },
    {
      tableName: 'scene_playlist',
      timestamps: true
    }
  )

  tbl.removeAttribute('id')
  return tbl
}

const TableRecommendCategory = new RecommendCategory()
const TableRecommendPlaylist = new RecommendPlaylist()
const TableSceneInfo = new SceneInfo()
const TableScenePlaylist = new ScenePlaylist()

module.exports = {
  TableRecommendCategory,
  TableRecommendPlaylist,
  TableSceneInfo,
  TableScenePlaylist
}
